import {Component, Vue} from 'vue-property-decorator'

@Component
export default class Base extends Vue {
  // picker 日期选择
  public pickerDate: any = {
    typeValue: '',
    typeOptions: [
      {
        value: 'register',
        label: '注册'
      }, {
        value: 'update',
        label: '更新'
      }, {
        value: 'login',
        label: '登录'
      }
    ],
    dateTypeValue: 'daterange',
    // 日期类型选项
    dateTypeOptions: [
      {
        value: 'daterange',
        label: '按天'
      }, {
        value: 'monthrange',
        label: '按月'
      }
    ],
    
    dateOptions: {
      disabledDate(time: any) {
        const nowTime = Date.now()
        return time.getTime() > (nowTime - (3600 * 1000 * 24))
      },
      shortcuts: [{
        text: '最近一周',
        onClick(picker: any) {
          const end = new Date()
          const start = new Date()
          start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
          end.setTime(end.getTime() - 3600 * 1000 * 24)
          picker.$emit('pick', [start, end])
        }
      }, {
        text: '最近一个月',
        onClick(picker: any) {
          const end = new Date()
          const start = new Date()
          start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
          end.setTime(end.getTime() - 3600 * 1000 * 24)
          picker.$emit('pick', [start, end])
        }
      }, {
        text: '最近三个月',
        onClick(picker: any) {
          const end = new Date()
          const start = new Date()
          start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
          end.setTime(end.getTime() - 3600 * 1000 * 24)
          picker.$emit('pick', [start, end])
        }
      }]
    },
    dateValue: ''
  }
}
